package com.unpay.skb.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
    private String configFile = "/unpay.properties";
    private String url;
    private String payurl;
    private String merId;
    private String key;
    private String proxyCode;

    private static Config config = new Config();

    private Config(){
        InputStream inStream = this.getClass().getResourceAsStream(configFile);
        try {
            Properties p = new Properties();
            p.load(inStream);
            this.url = p.getProperty("unpay.url");
            this.payurl = p.getProperty("unpay.payurl");
            this.merId = p.getProperty("unpay.merId");
            this.key = p.getProperty("unpay.key");
            this.proxyCode = p.getProperty("unpay.proxyCode");
            inStream.close();
        } catch (IOException e) {
            throw new RuntimeException("load unpay.properties error");
        }
    }

    public static Config instance(){
        return config;
    }

    public String getConfigFile() {
        return configFile;
    }

    public void setConfigFile(String configFile) {
        this.configFile = configFile;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getMerId() {
        return merId;
    }

    public void setMerId(String merId) {
        this.merId = merId;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getProxyCode() {
        return proxyCode;
    }

    public void setProxyCode(String proxyCode) {
        this.proxyCode = proxyCode;
    }

    public String getPayurl() {
        return payurl;
    }

    public void setPayurl(String payurl) {
        this.payurl = payurl;
    }
}
